package sortTest;

public class Pss implements Runnable{
	static Object S1 = new Object(), S2 = new Object();
	public void run()
	{
		if (Thread.currentThread().getName().equals("th1"))
		{
			synchronized (S1)
			{
				System.out.println("线程1锁定S1");
				synchronized (S2)
				{
					System.out.println("线程1搜定s2"); //
				}
			}
		}
		else
		{
			synchronized (S2)
			{
				System.out.println("线程2搜定s2");
				synchronized (S1)
				{
					System.out.println("线程2搜定s1"); //
				}
			}
		}
	}
	public static void main(String[] args)
	{
		Thread t1 = new Thread(new Pss(), "th1");
		Thread t2 = new Thread(new Pss(), "th2");
		t1.start();
		t2.start();
	}
}
